<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="page">
    <ul id="page" class="pagination"></ul>
</div>

<script>
    $(function () {
        let p = ajax(0, 5);
        javaex.page({
            id : "page",
            pageCount : p.totalPage,	// 总页数
            currentPage : 1,// 默认选中第几页
            // perPageCount : 10,	// 每页显示多少条，不填时，不显示该条数选择控件
            isShowJumpPage : true,	// 是否显示跳页
            totalNum : p.total,		// 总条数，不填时，不显示
            position : "right",
            callback : function(rtn) {
                ajax(rtn.pageNum, 5);
                console.log("当前选中的页数：" + rtn.pageNum);
                // console.log("每页显示条数：" + rtn.perPageCount);
            }
        });
    });

    function ajax(pageNum, perPageCount) {
        let p = {};
        pageNum = pageNum * perPageCount - 1;
        if (pageNum === -1)
            pageNum = 0;
        $.ajax({
            url: "/userManage?start="+pageNum+"&count="+perPageCount,
            async : false,
            success:function(data) {
                data = $.parseJSON(data);
                p.totalPage = data[0].totalPage;
                p.total = data[0].total;
                $("#tbody tr").remove();
                for (let i in data) {
                    console.log(data[i]);
                    $('#tbody').append("<tr>\n" +
                        "                    <td class=\"checkbox\"><input type=\"checkbox\" class=\"fill listen-1-2\" /> </td>\n" +
                        "                    <td>" + data[i].id + "</td>\n" +
                        "                    <td>" + data[i].cusLoginName + "</td>\n" +
                        "                    <td>" + data[i].cusName + "</td>\n" +
                        "                    <td>" + data[i].cusSex + "</td>\n" +
                        "                    <td>" + data[i].cusEmail + "</td>\n" +
                        "                    <td>" + data[i].cusBirthday + "</td>\n" +
                        "                </tr>");
                }
                javaex.render();
            }
        });
        return p;
    }
</script>